/** 教程链接：
 * https://dart.cn/language/#mixins
 */
// Mixin 示例：Piloted 用于描述载人飞船的功能

// Mixin 定义
mixin Piloted {
  int astronauts = 1;

  void describeCrew() {
    print('Number of astronauts: $astronauts');
  }
}

// 父类：太空飞船
class Spacecraft {
  final String name;

  Spacecraft(this.name);

  void describe() {
    print('Spacecraft: $name');
  }
}

// 使用 Mixin：PilotedCraft 继承 Spacecraft，并混入 Piloted 功能
class PilotedCraft extends Spacecraft with Piloted {
  PilotedCraft(String name) : super(name);
}

void main() {
  final craft = PilotedCraft('Orion');

  craft.describe();       // 来自 Spacecraft
  craft.describeCrew();   // 来自 Piloted
}
